package com.hrsoft.modules.sys.service.impl;

import com.hrsoft.common.utils.PageUtils;
import com.hrsoft.common.utils.Query;
import com.hrsoft.modules.sys.service.SysItemsService;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.hrsoft.modules.sys.dao.SysItemsDao;
import com.hrsoft.modules.sys.entity.SysItemsEntity;


@Service("sysItemsService")
public class SysItemsServiceImpl extends ServiceImpl<SysItemsDao, SysItemsEntity> implements SysItemsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<SysItemsEntity> query = new QueryWrapper<>();
        if (params.get("key") != null) {
            query.like("code", params.get("key")).or().like("full_name", params.get("key"));
        }
        query.orderByDesc("id");
        IPage<SysItemsEntity> page = this.page(
                new Query<SysItemsEntity>().getPage(params),
                query
        );

        return new PageUtils(page);
    }

}